package com.zmn.uac.dubbo.impl;

import com.zmn.common.dto2.ResponseDTO;
import com.zmn.uac.business.enums.ThirdInfoEnum;
import com.zmn.uac.business.interfaces.oauth.login.LoginBaseBService;
import com.zmn.uac.common.constant.DubboConsts;
import com.zmn.uac.common.dio.oauth.login.TempCodeDIO;
import com.zmn.uac.common.dio.oauth.login.UserAuthLoginDIO;
import com.zmn.uac.common.dro.oauth.login.UserAuthLoginDRO;
import com.zmn.uac.dubbo.interfaces.oauth.login.LoginBaseRemoteService;
import com.zmn.uac.util.BeanUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;

import javax.validation.constraints.NotNull;

/**
 * 登录对外dubbo接口
 *
 * @author Rananquan
 * @since 2022年5月16日 18点38分
 */
@Slf4j
@DubboService(version = DubboConsts.INTERFACE_VERSION, validation = "true")
public class LoginBaseRemoteServiceImpl implements LoginBaseRemoteService {

    LoginBaseBService loginBaseBusinessService;

    @Override
    public ResponseDTO<UserAuthLoginDRO> officialAccountAuthLogin(@NotNull(message = "公众号授权用户登陆参数UserAuthLoginDIO不能为空") UserAuthLoginDIO dio) {
        return null;
    }

    @Override
    public ResponseDTO<UserAuthLoginDRO> login(@NotNull(message = "小程序授权用户登陆参数UserAuthLoginDIO不能为空") UserAuthLoginDIO dio) {
        return null;
    }

    @Override
    public ResponseDTO<String> getOpenIdByTempCode(@NotNull(message = "授权code不能为空") TempCodeDIO tempCodeDIO) {
        loginBaseBusinessService = BeanUtil.getBean(ThirdInfoEnum.getLoginBaseBService(tempCodeDIO.getThirdType()).getClass());
        return loginBaseBusinessService.getOpenIdByCode(tempCodeDIO);
    }
}
